package easy.Excel表列序号;


public class Solution2 {
    public int titleToNumber(String columnTitle) {
        int result = 0;
        int len = columnTitle.length();
        for (int i = 0; i < len; i++) {
            result = result * 26 + (columnTitle.charAt(i) - 'A' + 1);
        }
        return result;
    }

    public static void main(String[] args) {
        String columnTitle = "AB";
        String columnTitle2 = "ZY";
        Solution2 solution = new Solution2();
        System.out.println(solution.titleToNumber(columnTitle));
        System.out.println(solution.titleToNumber(columnTitle2));
    }
}
